<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/9/14
 * Time: 下午5:32
 */

namespace app\club\logic;


use extend\Functions;
use extend\STATUS_CODE;

class Area
{
    /**
     * @purpose 通过PID获取区域列表
     * @param int $pid
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function itemByPid (int $pid = 0): array
    {
        $model          = new \app\model\Area();
        $list           = $model
            ->where('pid', $pid)
            ->field('id,pid,name,short_name,area_code,merger_name,pinyin,lng,lat')
            ->order('zip_code asc')
            ->select();
        return Functions::result(
            STATUS_CODE::SUCCESS,
            $list
        );
    }
}